Once you have created your VB program, you need a way to distribute it to your users. You could create your own setup program, or purchase a third party program to do it for you. However, the first would be very time consuming, and the second would be very expensive.

An alternative option is the Package & Deployment wizard that is bundled with Visual Basic. It allows you to create a setup program for your application in a few minutes. It is not amazingly flexible, but is fine for most basic applications. This tutorial will show you how to use it.

You can start the Package & Deployment wizard using two methods...

Method 1

To load the Package & Deployment wizard, go to the same location on the start menu where the VB icon is, click the Tools item, and then select Package & Deployment Wizard.

Next, you need to select the VB project that you want to use by clicking Browse.

Method 2

An alternative method is to open the VB project you want to create a setup program for, and select Package & Deployment wizard from the Add-In menu in VB. If the option is not visible, choose Add-In Manager and double click Package and Deployment Wizard.

Whichever method you choose to use, you now need to click the Package button. 

The Wizard might ask you to locate the EXE file of your project (if it doesn't exist you can compile it). It might also warn you that the project files a newer than the EXE (ie that you have changed the source code since you compiled the program). You can either choose to re-compile the program or use the out-of-date version.
You now have a choice of the type of Package you want to create. For this tutorial, select Standard Setup Package and click Next. I have explained the different package types below.

Standard Setup Package - Creates a standard setup program (setup.exe) which can then be distributed on a floppy disk, CD Rom or other media. (It can also be downloaded from the internet)

Dependancy File - This generates dependancy file that stores information on what files the program or component needs. This can then be used by the Package & Deployment Wizard (or another setup wizard) when including the program or component in another setup program.

In this screen we need to choose where the setup files will be placed. By default, this is a folder named 'Package' in your project folder.

If you do not want them to be created in the default location, you can select another location. To do this, simply browse to the correct folder. If you want the files placed in a new folder, simply click the New Folder button.

Then click Next to move to the next screen.

The next screen lists all the files that the Package & Deployment Wizard thinks your program needs.

If there are other components needed that the Wizard has not detected, you can click Add. You can also use this to add help files or a readme.txt file for your application.

You can also uncheck some items so that they are not included in the setup program. Bear in mind, however, that if you don't include them, your application may not successfully run. 

If you want to know what each item does, the most common items are explained below. You can skip this part if you aren't interested!

*.exe - Your application!

Setup.exe - The setup program that will be generated.

Setup1.exe - Another generated program. This is copied to the hard disk of the target computer and then executed, which allows your setup files to span multiple disks.

St6Unst.exe - This program will allow your application to be uninstalled.

VB6 Runtime and OLE Automation - These files (msvbvm60.dll and xxxx.dll) are required for all VB applications to run. In some cases, you might decide not to include these, if you know that you users already have this installed. If you are distributing your program over the internet, you might also ask users to download these files from http://ftp.microsoft.com/dsgsash if they need them, which would reduce your setup programs size by almost 1MB.

VB6StKit.dll - This DLL contains functions required by the generated setup program. (Required)

MSComCtl32.ocx - This is included if your application uses the Microsoft Common Controls.

RichTxt32.ocx and RichTxt32.dll - Required if your application uses the RichTextBox

Note that if you use the WebBrowser control, no files are included. This is because the control needs Internet Explorer installed to work - if it is installed, the control will work. If IE isn't installed the control won't work until it is! (This is one of the conditions for using the WebBrowser control)

Click next to go to the next screen.

The Cab options screen allows you to create one big setup file, or split it up into several sections.

If you are going to distribute your application on floppy disks, CD Rom or other media, choose the Multiple Cabs option and select the capacity of the media. If the setup program does not fit on one disk, it will automatically 'span' it across multiple disks, and prompt the user to enter each disk when needed.

If you are going to distribute your application on the internet, or via a network, you can select the Single Cab option. Your setup program will then be compiled into one setup file, whatever its size.

Click the next button to proceed.

Installation Title

This screen is very simple; all it wants to know is the text that should be displayed during setup, for example 'Microsoft Word Setup'.

Start Menu Items

This screen allows us to specify what installed files can be accessed via the Start Menu.

You can use the New Group and New Item buttons to add the items and folders you want added to the Start Menu.

If you want to have just one item on the start menu, then simply click New Item and select your EXE file.

If you want more than one item to be added (such as your program, and a link to the readme file), then you usually create a folder and place the icons in there. To do this, click New Group. Enter the name for the group (such as 'Microsoft Office'), and click OK. Next, click New Item, and select the files you want added to this group (such as Microsoft Word and Readme).

The next screen allows you to choose where your files (ie your EXE, and its readme file) are installed. By default, they are placed in the folder that is chosen by the user (ie C:Program FilesMy Example Program), and for this example, we will leave this alone.

However, the wizard does allow you to choose another location. This is particularly useful if, for example, you have included a number of DLLs, you may choose to have them installed in the WindowsSystem folder, instead of your application folder. If you want to do this, simply change the InstallLocation field for the file to $(WinSysPath). The other locations are listed in the drop down box.

In the next screen, all you need to do is enter a name for the setup script to be saved as. This is so that you can re-compile the setup program when your application changes, without having to re-enter all the settings.

Next, click Finish, and your setup program will be compiled, and then a report will be displayed when the wizard has finished.

Now that your setup program has been created, all you need to do is test it! To do this, go to the folder you specified, and double click on Setup.exe... and your very own setup program will be run.

You can then copy these files onto a floppy disk or other media to distribute your program. Note that you need ALL the files that are generated in the folder. These are usually Setup.exe, Setup.lst, and a number of *.Cab files, depending on the CAB options you specified.

And that's it! Your very own setup program.... made easy by the Package & Deployment Wizard.

After a while, however, you may find that you need capabilities it does not have. If this is the case, you can...
1) Take a look at, and customize the VB source code of the setup program it creates. You can find this in %VBInstallPath%WizardsPDWizardSetup1. [It is recommended that you back up this folder first!] Once you have finished your customization, you need to re-run the Package & Deployment Wizard. (Thanks to Vincent Kemp for that) 
2) Try another free program, the new Visual Studio Installer which uses the Windows Installer technology
3) Try a commercial product from InstallShield, or Wise Solutions. 
